var mysql = require('mysql');
 
const mysqlConfig = require('../../config/config.default')

const connection = mysql.createConnection(mysqlConfig.mysqlConfig)

connection.connect(function(err){
    if(err){
        return console.error(err)
    }
    console.log('mysql connction success')
})

const query = (sql)=>{
    return new Promise((resolve, reject) => {
        connection.query(sql , function(error,result){
            if(error){
                reject(error)
                return
            }
            resolve(result)
        })
    })
}

module.exports=query